<template>
  <div>
    <van-sticky>
      <van-nav-bar
        title="写影评"
        left-text="返回"
        right-text="发布"
        left-arrow
        @click-left="onClickLeft"
        @click-right="onClickRight"
      />
    </van-sticky>
    <van-field
      v-model="message"
      rows="25"
      autosize
      label="留言"
      type="textarea"
      maxlength="3000"
      placeholder="请输入留言"
    />
  </div>
</template>

<script>
import axios from "axios";
import qs from "querystring";
export default {
  data() {
    return {
      message: "",
    };
  },
  methods: {
    onClickLeft() {
      this.$router.push({
        name: "infoSearch",
        params: { movie_id: this.$route.params.movie_id },
      });
    },
    onClickRight() {
      // movie_id=${this.$route.params.movie_id}&username=${localStorage.getItem('username')}&content=${this.message}
      let obj = {
        movie_id: this.$route.params.movie_id,
        username: sessionStorage.getItem("username"),
        content: this.message,
      };
      axios
        .post(`http://localhost:8888/movie/writeComment`, qs.stringify(obj))
        .then((res) => {
          console.log(res);
        });
      this.$router.push({
        name: "infoSearch",
        params: { movie_id: this.$route.params.movie_id },
      });
    },
  },
};
</script>

<style></style>
